package com.ruoyi.biz.rest.system;

import com.ruoyi.biz.system.service.IBizAreaService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 区域Controller
 *
 * @author Fei.Cong
 * @date 2023-04-21
 */
@RestController
@RequestMapping("/api/v1/system/area")
public class RestAreaController extends BaseController {

    @Autowired
    private IBizAreaService bizAreaService;

    /**
     * 根据区域id查询所属部门id，未找到，返回顶级部门id
     */
    @Log(title = "根据区域id查询所属部门id", businessType = BusinessType.REST)
    @GetMapping(value = "/getDeptId/{areaId}")
    public AjaxResult remoteAdd(@PathVariable(name = "areaId") String areaId) {
        return success(bizAreaService.getDeptIdByAreaCode(areaId));
    }
}
